package edu.sjb.map;

import edu.sjb.Drawable;
import edu.sjb.characters.GameCharacter;
import edu.sjb.characters.Mario;
import edu.sjb.constants.ImageConstants;

public class Pipe extends MapObject {
	public Pipe() {
		super();
	}

	@Override
	public void hitAgainstMario(Mario m) {
		if ((m.posY() <= posY())
		        && ((m.posX() + m.sizeX() > posX() + 4) || (m.posX() > posX()))) {
			m.setPosY(posY() - m.sizeY());
		}
		else {
			if (m.posX() < posX()) {
				m.setCanGoRight(false);
			}
			else {
				m.setCanGoLeft(false);

			}
		}
	}

	@Override
	public void characterCollide(GameCharacter gc) {
		if (gc.posX() < posX()) {
			gc.setCanGoRight(false);
		}
		else {
			gc.setCanGoLeft(false);

		}
	}

	@Override
	public void run() {
	}

	protected Object clone() {
		Pipe newP = new Pipe();
		Drawable newImg = new Drawable(ImageConstants.PIPE, false);
		newP.setImage(newImg);
		return newP;
	}
}
